-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: return constructable class from require('module')
#9711
Conversation
: fileURLToPath(modulePath); | ||
|
||
if (!path.isAbsolute(filename)) { | ||
return this._getMockedNativeModule(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignoring whitespace makes this diff readable
https://github.com/facebook/jest/pull/9711/files?w=1
} | ||
|
||
private _getMockedNativeModule(): typeof nativeModule.Module { | ||
if (this._moduleImplementation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poor man's cache. might be better to stick in in the module cache we have already
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
require('module')
apparently returns a class with static properties, and not an object. This is not documented, but probably old behavior. We broke this in #9469. This is a quick and dirty "fix". Ideas welcome!Fixes #9710
/cc @doniyor2109
Test plan
Unit test added